package com.example.actearly_revised;

import java.util.Vector;
import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public class MilestonePageSwiper extends PagerAdapter {

	private Context mContext;
	private Vector<View> pages;
	private View updatableText;
	public MilestonePageSwiper(Context context, Vector<View> pages) {
		this.mContext=context;
		this.pages=pages;
		SQLogic conn = new SQLogic(mContext);
		conn.open();
		QuestionsObject test = conn.RetrieveQuestions(18,1,"s");
		String question[] = new String[test.count()];
		pages.setSize(test.count());
		System.out.println(test.count());
		conn.close();

	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		View page = pages.get(position);
		container.addView(page);
		return page;
	}

	@Override
	public int getCount() {
		return pages.size();
	}

	@Override
	public boolean isViewFromObject(View view, Object object) {
		return view.equals(object);
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		container.removeView((View) object);
	}

}



/*package com.example.actearly_revised;

import com.example.actearly_revised.QuestionsObject.Node;

import android.content.Context;
import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;

//getCount value gives how many total pages there are. the middle number is always the 
//center page
public class QuicklistPageAdapter extends PagerAdapter {
	String question[];
	String keys[];
	QuestionsObject test;
	Node question_node;
	String milestoneNames[];
	private Context mContext;

	public  QuicklistPageAdapter(Context context){
		this.mContext=context;
	}

	public int getCount() {
		return 3;
	}
	public Object instantiateItem(View collection) {
		LayoutInflater inflater = (LayoutInflater) collection.getContext()
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		int resId = 0;


		// can use this later to swap between milestone groups
		 switch (position) {
        case 0:
            resId = R.layout.farleft;
            break;
        case 1:
            resId = R.layout.left;
            break;
        case 2:
            resId = R.layout.middle;
            break;
        case 3:
            resId = R.layout.right;
            break;
        case 4:
            resId = R.layout.farright;
            break;

        }
		View view = inflater.inflate(resId, null);
		((ViewPager) collection).addView(view, 0);
		return view;
	}
	@Override
	public void destroyItem(View arg0, int arg1, Object arg2) {
		((ViewPager) arg0).removeView((View) arg2);
	}
	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		return arg0 == ((View) arg1);
	}
	@Override
	public Parcelable saveState() {
		return null;
	}
}*/